home *** CD-ROM | disk | FTP | other *** search
- unit ServObj;
-
- interface
-
- uses
- ComObj, ActiveX, Server_TLB;
-
- type
- TBinaryData = class(TAutoObject, IBinaryData)
- protected
- function Get_Data: OleVariant; safecall;
- procedure Set_Data(Value: OleVariant); safecall;
- end;
-
- implementation
-
- uses ComServ, ServMain;
-
- function TBinaryData.Get_Data: OleVariant;
- var
- P: Pointer;
- L: Integer;
- begin
- // Move data from memo into array
- L := Length(MainForm.Memo.Text);
- Result := VarArrayCreate([0, L - 1], varByte);
- P := VarArrayLock(Result);
- try
- Move(MainForm.Memo.Text[1], P^, L);
- finally
- VarArrayUnlock(Result);
- end;
- end;
-
- procedure TBinaryData.Set_Data(Value: OleVariant);
- var
- P: Pointer;
- L: Integer;
- S: string;
- begin
- // Move data from array into memo
- L := VarArrayHighBound(Value, 1) - VarArrayLowBound(Value, 1) + 1;
- SetLength(S, L);
- P := VarArrayLock(Value);
- try
- Move(P^, S[1], L);
- finally
- VarArrayUnlock(Value);
- end;
- MainForm.Memo.Text := S;
- end;
-
- initialization
- TAutoObjectFactory.Create(ComServer, TBinaryData, Class_BinaryData,
- ciSingleInstance, tmApartment);
- end.
-